home *** CD-ROM | disk | FTP | other *** search
/ ring.yamanashi.ac.jp/pub/pc/freem/action/ / action.zip / umiact_ver1_1.zip / ‚¤‚Ý‚Ë‚±ƒAƒNƒVƒ‡ƒ“Iver1.1 / ‰¹ŠyŽ©“®ƒRƒs[ƒoƒbƒ`.vbs next >
Text File  |  2010-08-08  |  8KB  |  343 lines

  1. Option Explicit
  2.  
  3. ''' Åëè·ë╗Åêù¥
  4. Dim FSO
  5. Set FSO = CreateObject("Scripting.FileSystemObject")
  6.  
  7. Dim objWshShell
  8. Set objWshShell = CreateObject("WScript.Shell")
  9.  
  10. dim wcs: set wcs = new WCSwitch
  11.  
  12.  
  13. ' âXâNâèâvâgé╠âfâBâîâNâgâè
  14. Dim currentDir 
  15. currentDir = Replace(WScript.ScriptFullName, WScript.ScriptName,"")
  16.  
  17.  
  18. Dim gomi
  19.  
  20.  
  21. ' Åêù¥îoë▀âìâO
  22. Dim logFile
  23. Set logFile = FSO.OpenTextFile(currentDir & "\log.txt", 2, True)
  24.  
  25.  
  26. ' î⌐é┬é⌐éτé╚é⌐é┴é╜âtâ@âCâïâèâXâg
  27. Dim logNotFound
  28. Set logNotFound = FSO.OpenTextFile(currentDir & "\notfoundlist.txt", 2, True)
  29.  
  30.  
  31.  
  32. ''' ó07th_ExpansionüvâtâHâïâ_é≡ÆTé╖
  33. ''' îƒì⌡æ╬Å█âfâBâîâNâgâèüFüuProgramFilesüvüuâhâëâCâuÆ╝ë║üv
  34.  
  35. '' ProgramFiles
  36. Dim file, sub_folder, path, program_files
  37. program_files = expandEnvironment("%ProgramFiles%")
  38. path = findMainFolder(FSO.GetFolder(program_files))
  39.  
  40.  
  41. '' âhâëâCâuÆ╝ë║
  42. If path = -1 Then
  43.    Dim dc 
  44.    Set dc = FSO.Drives
  45.  
  46.    Dim d
  47.    For Each d in dc
  48.        If d.IsReady Then
  49.       path = findMainFolder(FSO.GetFolder(d.DriveLetter & ":\"))
  50.       If path <> -1 Then
  51.          Exit For
  52.       End If
  53.        End If
  54.    Next
  55. End If
  56.  
  57.  
  58. If path = -1 Then
  59.    Call exitProgram("07th_ExpansionâtâHâïâ_é¬î⌐é┬é⌐éΦé▄é╣é±é┼é╡é╜üB")
  60. End If
  61.  
  62.  
  63. ''' éñé▌é╦é▒âtâHâïâ_é≡î⌐é┬é»éΘ
  64. Dim umineko_folders()
  65. ReDim umineko_folders(0)
  66. Call findUminekoFolders(FSO.GetFolder(path),umineko_folders)
  67. gomi = shiftArray(umineko_folders)
  68. printAndLog("ë║ïLé╠âtâHâïâ_é¬î⌐é┬é⌐éΦé▄é╡é╜üB" & vbCrLf & Join(umineko_folders,vbCrLf))
  69.  
  70.  
  71. ''' BGM,ME,SEâtâHâïâ_é≡î⌐é┬é»éΘ
  72. Dim umineko, BGM_folders(), SE_folders()
  73. ReDim BGM_folders(0), SE_folders(0)
  74. For Each umineko In umineko_folders
  75.     Call findBGMFolder(FSO.GetFolder(umineko), BGM_folders)
  76.     Call findSEFolder(FSO.GetFolder(umineko) , SE_folders)
  77. next
  78. gomi = shiftArray(BGM_folders)
  79. gomi = shiftArray(SE_folders)
  80. PrintAndLog("ë║ïLé╠âtâHâïâ_é¬î⌐é┬é⌐éΦé▄é╡é╜üB" & vbCrLf & Join(BGM_folders,vbCrLf))
  81. PrintAndLog("ë║ïLé╠âtâHâïâ_é¬î⌐é┬é⌐éΦé▄é╡é╜üB" & vbCrLf & Join(SE_folders,vbCrLf))
  82.  
  83.  
  84.  
  85. ''' Find
  86. PrintAndLog(vbCrLf & "========== BGM ============")
  87. Dim game_bgm_folder
  88. Set game_bgm_folder = FSO.GetFolder(currentDir & "\bgm")
  89. Call findMusic(BGM_folders, game_bgm_folder, currentDir & "\bgm")
  90. Set game_bgm_folder = Nothing
  91.  
  92.  
  93. PrintAndLog(vbCrLf & "========== SE ============")
  94. Dim game_se_folder
  95. Set game_se_folder = FSO.GetFolder(currentDir & "\wave")
  96. Call findMusic(SE_folders, game_se_folder, currentDir & "\wave")
  97. Set game_se_folder = Nothing
  98.  
  99.  
  100.  
  101. ''' ÅIù╣Åêù¥
  102. MsgBox "âRâsü[è«ù╣é╡é▄é╡é╜üB"
  103. postProcess
  104.  
  105.  
  106. '''''''''''''
  107. ''  è╓Éö   ''
  108. '''''''''''''
  109. Function findMainFolder(obj_folder)
  110.     Dim path
  111.     path = -1
  112.     For Each file in obj_folder.SubFolders
  113.         If file.Name = "07th_Expansion" Then
  114.         path = file.path
  115.         Exit For
  116.     End If    
  117.     next
  118.  
  119.     findMainFolder = path
  120. End Function
  121.  
  122.  
  123. Sub findUminekoFolders(obj_folder, umineko_folders)
  124.     Dim folder
  125.     For Each folder in obj_folder.SubFolders
  126.         Call pushArray(umineko_folders, folder.path)
  127.     next    
  128. End Sub
  129.  
  130.  
  131. Sub findBGMFolder(obj_folder, BGM_folders) 
  132.     Dim regEx
  133.     Set regEx        = New RegExp
  134.     regEx.Pattern    = "BGM"
  135.     regEx.Global     = True
  136.     regEx.IgnoreCase = True
  137.  
  138.     Dim folder
  139.     For Each folder In obj_folder.SubFolders
  140.         If regEx.Test(folder.name) Then
  141.        Call pushArray(BGM_folders, folder.path)
  142.     End If
  143.     Next
  144.  
  145.     Set regEx = Nothing
  146. End Sub
  147.  
  148.  
  149. Sub findSEFolder(obj_folder, SE_folders)
  150.     Dim folder
  151.     For Each folder In obj_folder.SubFolders
  152.         If folder.name = "SE" Or folder.name = "ME" Or folder.name = "sys_se" Then
  153.        Call pushArray(SE_folders, folder.path)
  154.     End If
  155.     Next
  156. End Sub
  157.  
  158.  
  159. Sub findMusic(music_folders, game_music_folder, dst)
  160.     Dim find_flag
  161.  
  162.     Dim music_folder
  163.     Dim file, file_name
  164.     For Each file In game_music_folder.files
  165.         file_name = file.Name
  166.     printAndLog "üu" & file_name & "üv" & "îƒì⌡Æå..."
  167.     find_flag = 0
  168.     For Each music_folder In music_folders 
  169.         Dim path
  170.         path = findData(FSO.GetFolder(music_folder), file_name) 
  171.  
  172.         If path <> "" Then
  173.                 Dim src
  174.                 Set src = FSO.GetFile(Path)
  175.              printAndLog path & vbCrLf
  176.                 src.Copy dst & "\" & file_name
  177.             find_flag = 1
  178.         Set src = Nothing
  179.                 Exit For
  180.             End If
  181.          Next
  182.  
  183.          If find_flag <> 1 Then
  184.             PrintAndLog "Not Found" & vbCrLf
  185.         logNotFound.WriteLine dst & ":" & file_name
  186.          End If
  187.    Next
  188. End Sub
  189.  
  190.  
  191. Function findData(obj_folders, keyname)
  192.     Dim regEx
  193.     Set regEx = New RegExp
  194.     regEx.Pattern = "\.(.*)?"
  195.     regEx.IgnoreCase = True
  196.  
  197.     Dim oMatch, oMatches, ext
  198.     Set oMatches = regEx.Execute(keyname)
  199.     Set oMatch = oMatches(0)
  200.     Dim name    
  201.     name = regEx.Replace(keyname, LCase(oMatch.SubMatches(0)))
  202.  
  203.     For Each file in obj_folders.Files
  204.         Dim file_name
  205.     Set oMatches = regEx.Execute(file.Name)
  206.     Set oMatch   = oMatches(0)
  207.     file_name = regEx.Replace(file.Name, LCase(oMatch.SubMatches(0)))
  208.         If file_name = name Then
  209.        findData = file.path
  210.     End If
  211.     next
  212. End Function 
  213.  
  214.  
  215. Function arraySize(array)
  216.     Dim n
  217.     arraySize = UBound(array) - LBound(array) + 1
  218. End Function
  219.  
  220.  
  221. Sub pushArray(array, f)
  222.     Dim size
  223.     ReDim Preserve array(UBound(array)+1)      
  224.     array(UBound(array)) = f
  225. End Sub
  226.  
  227.  
  228. Function popArray(array) 
  229.     Dim f
  230.     f = array(UBound(array))
  231.     ReDim Preserve array(UBound(array) - 1)
  232.  
  233.     popArray = f
  234. End Function
  235.  
  236.  
  237. Function shiftArray(array)
  238.     Dim p
  239.     p = array(0)
  240.  
  241.     Dim i
  242.     For i = 1 To UBound(array) Step 1
  243.         array(i-1) = array(i)
  244.     Next
  245.     ReDim Preserve array(UBound(array) - 1)
  246.  
  247.     shiftArray = p
  248. End Function
  249.  
  250.  
  251. Sub unShiftArray(array, f)
  252.     ReDim Preserve array(UBound(array) + 1)
  253.     
  254.     Dim i
  255.     For i = 0 To UBound(array)-1  Step 1
  256.         array(i+1) = array(i)
  257.     Next
  258.  
  259.     array(0) = f
  260. End Sub
  261.  
  262.  
  263. Sub PrintAndLog(msg)
  264.     If lcase(right(WScript.Fullname,11)) = "cscript.exe" Then
  265.         WScript.Echo msg
  266.     End If
  267.     logFile.WriteLine(msg)
  268. End Sub
  269.  
  270.  
  271. class WCSwitch
  272.     private m_ws, m_env, m_EnvVarName, m_IsCScript 
  273.  
  274.     private sub Class_Initialize()
  275.         set m_ws = CreateObject("WScript.Shell")
  276.         set m_env = m_ws.environment("Volatile")
  277.         m_IsCscript = lcase(right(WScript.Fullname,11)) = "cscript.exe"
  278.         dim vName
  279.         vName = WScript.ScriptFullName
  280.         vName = replace(vName,"\","_")
  281.         vName = replace(vName,":","_")
  282.         m_EnvVarName = vName
  283.         if not m_IsCscript then spawn
  284.     end sub
  285.  
  286.     private sub Class_Terminate()
  287.         if m_IsCScript and len(m_env(m_EnvVarName)) > 0 then
  288.             msgbox "âvâìâOâëâÇé≡ÅIù╣é╡é▄é╖üB",vbOKOnly,"CScripté⌐éτé╠Æ╩Æm"
  289.             m_env.remove(m_EnvVarName)
  290.         end if
  291.     end sub
  292.  
  293.     private sub spawn
  294.         const DQ = """", HDQ = "^"""
  295.  
  296.         dim oExec,sCmdline
  297.         sCmdline = "cmd /C " & DQ & _
  298.             "start cscript //nologo " & _
  299.             HDQ & WScript.ScriptFullName & HDQ &  DQ
  300.         m_env(m_EnvVarName)="1"
  301.         set oExec = m_ws.Exec(sCmdLine)
  302.         do while oExec.status = 0
  303.             wscript.sleep 100
  304.         loop
  305.         wscript.quit
  306.     end sub
  307.  
  308. end class
  309.  
  310.  
  311. Function expandEnvironment(environment)
  312.    On Error Resume Next
  313.  
  314.    Dim objWshShell
  315.    Dim strEnvironment
  316.  
  317.    Set objWshShell = WScript.CreateObject("WScript.Shell")
  318.    If Err.Number = 0 Then
  319.       expandEnvironment = objWshShell.ExpandEnvironmentStrings(environment)
  320.    Else
  321.       WScript.Echo "âGâëü[üF" & Err.Description
  322.    End If
  323.  
  324.    Set objWshShell = Nothing
  325. End Function        
  326.  
  327.  
  328. Sub exitProgram(msg) 
  329.     MsgBox msg
  330.     PostProcess
  331.     WScript.Quit
  332. End Sub
  333.     
  334.  
  335. Sub postProcess
  336.     logFile.Close
  337.     logNotFound.Close 
  338.     Set FSO = Nothing
  339.     Set objWshShell = Nothing
  340.     Set logFile = Nothing
  341.     Set objWshShell = Nothing
  342.     Set wcs = Nothing
  343. End Sub